    // * desc: 下载参数入口
    // * @param base64  ：返回数据的blob对象或链接
    // * @param fileName  ：下载后文件名标记
    export function downloadFileByBase64(base64, fileName) {
      var myBlob = dataURLtoBlob(base64)
      var myUrl = URL.createObjectURL(myBlob)
      downloadFile(myUrl, fileName)
    }


    //将完整的base64转换为blob
    function dataURLtoBlob(dataurl) {
      var arr = dataurl.split(","),
        mime = arr[0].match(/:(.*?);/)[1],
        bstr = atob(arr[1]),
        n = bstr.length,
        u8arr = new Uint8Array(n)
      while (n--) {
        u8arr[n] = bstr.charCodeAt(n)
      }
      return new Blob([u8arr], {
        type: mime
      })
    }

    // * desc: 下载方法
    // * @param url  ：返回数据的blob对象或链接
    // * @param fileName  ：下载后文件名标记
    function downloadFile(url, name = "name") {
      var a = document.createElement("a")
      a.setAttribute("href", url)
      a.setAttribute("download", name)
      a.setAttribute("target", "_blank")
      let clickEvent = document.createEvent("MouseEvents")
      clickEvent.initEvent("click", true, true)
      a.dispatchEvent(clickEvent)
    }




    /*将base64转换为file继承自blob*/
    export function base64toFile(dataBase64, filename = 'file') {
      let arr = dataBase64.split(',')
      let mime = arr[0].match(/:(.*?);/)[1] //设置file文件流的type名称
      let suffix = mime.split('/')[1] //设置file文件流的name名称
      const bstr = window.atob(arr[1]);
      let n = bstr.length
      const u8arr = new Uint8Array(n)
      while (n--) {
        u8arr[n] = bstr.charCodeAt(n)
      }
      return new File([u8arr], `${filename}.${suffix}`, {
        type: mime
      })
    }

    export function downLoadByUrl(url, name) {
      let image = new Image()
      image.setAttribute('crossOrigin', 'anonymous')
      image.src = url
      image.onload = () => {
        let canvas = document.createElement('canvas')
        canvas.width = image.width
        canvas.height = image.height
        let ctx = canvas.getContext('2d')
        ctx.drawImage(image, 0, 0, image.width, image.height)
        canvas.toBlob((blob) => {
          let url = URL.createObjectURL(blob)
          let eleLink = document.createElement('a')
          eleLink.download = name
          eleLink.href = url
          eleLink.click()
          eleLink.remove()
          // 用完释放URL对象
          URL.revokeObjectURL(url)
        })
      }
    }